import React, { Component } from 'react';
import MHeader from "../../components/MHeader/index";
import profile from '../../common/images/profile.png';
import './index.less'
import {Link} from 'react-router-dom';
import user from '../../redux/actions/user';
import Alert from "../../components/Alert/index";
import {connect} from 'react-redux';
import * as action from '../../redux/actions/user'

class Reg extends Component {
    reg=()=>{
        this.props.reg({username:this.username.value,password:this.password.value})
        console.log(this.username.value,this.password.value)
    }
    render() {
        return (
            <div className="login">
                <MHeader title="登录" />
                <div className="login-image">
                    <img src={profile} />
                </div>
                <form onSubmit={this.handleSubmit}>
                    <input ref={(element)=>{this.username = element}} type="text" placeholder="用户名" />
                    <input ref={(element)=>{this.password = element}} type="text" placeholder="密码" />
                    <p><a onClick={this.reg} >注册</a></p>
                </form>
                <Alert error={this.props.err} />
            </div>
        );
    }
}

export default connect(state=>({...state}),action)(Reg);
